﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>判断变量是否已经定义</title>
    <script type="text/javascript" language="JavaScript">
        function judge(){
            if(typeof(iTxt) === "undefined"){
                alert("iTxt变量未定义");
            }else{
                alert("iTxt变量已经定义");
            }
        }
    </script>
    
</head>
<body>
<input id="Button1" type="button" value="判断" onclick="judge()" />
</body>
</html>